{extend name="layout" /}
{block name="content"}
<div class="row">
  <div class="col-xs-6" style="width: 57%;">
    <form id="searchForm">
      <div class="seardiv" style="width: 10%;float: left;">
        <select name="status" class="form-control input-sm">
          <option value="3">全部</option>
          <option value="0">未支付</option>
          <option value="1" selected>充值成功</option>
          <option value="2">充值失败</option>
        </select>
      </div>
      <div class="seardiv" style="width: 15%;float: left;">
        <select name="dealerid" class="form-control input-sm">
          <option value="">请选择经销商</option>
          {volist name="deallist" id="v"}
          <option value="{$key}">{$v}</option>
          {/volist}
        </select>
      </div>
      <div class="seardiv" style="width: 10%;float: left;">
        <select name="type" class="form-control input-sm">
          <option value="0" selected>充值类型</option>
          <option value="1">新注册会员</option>
          <option value="2">续费会员</option>
        </select>
      </div>
      <div class="seardiv" style="width: 15%;float: left;">
        <select name="paytype" class="form-control input-sm">
          <option value="0" selected>支付方式</option>
          <option value="1">微信</option>
          <option value="2">购车线索奖励</option>
          <option value="3">购买保养套餐奖励</option>
          <option value="4">完成任务奖励会员</option>
        </select>
      </div>
      <div class="seardiv" style="width: 13%;float: left;">
        <input class="form-control input-sm" placeholder="选择开始时间" type="text" name="startdate" id="startdate"
               AUTOCOMPLETE="off" value="">
      </div>
      <div class="seardiv" style="width: 13%;float: left;">
        <input class="form-control input-sm" placeholder="选择结束时间" type="text" name="enddate" id="enddate"
               AUTOCOMPLETE="off" value="">
      </div>
      <div class="seardiv input-group input-group-sm demoTable" style="width: 24%;float: left;">
        <input type="text" class="form-control input-sm" name="keywords" id="demoReload" autocomplete="off"
               placeholder="输入订单号或经纪人名字">
        <span class="input-group-btn">
          <button type="button" class="btn btn-info btn-flat layui-btn" data-type="reload">搜 索</button>
        </span>
      </div>
    </form>
  </div>
  <div class="col-xs-6" style="text-align: right; width: 43%;">
    <button type="button" class="btn btn-info btn-sm export" title="购买会员订单"><i class="fa fa-edit"></i> 数据导出</button>
  </div>
</div>
<table class="layui-table"
  lay-data="{height: 'full-75', cellMinWidth: 80, page: true, id:'lists',limit:30, url:'{:url('data_show_where',['order'=>'desc'])}'}"
  lay-filter="lists">
  <thead>
    <tr class="layui-colla-content">
      <th lay-data="{type:'checkbox'}">ID</th>
      <th lay-data="{field:'id', sort: true,width:80}">ID</th>
      <th lay-data="{field:'ordersn'}">订单号</th>
      <th lay-data="{field:'realname'}">经纪人</th>
      <th lay-data="{field:'dealname'}">所属经销商</th>
      <th lay-data="{field:'price'}">价格</th>
      <th lay-data="{field:'payprice'}">支付金额</th>
      <th lay-data="{field:'disprice'}">折扣</th>
      <th lay-data="{field:'payname'}">支付方式</th>
      <th lay-data="{field:'description'}">简介</th>
      <th lay-data="{field:'statusname'}">状态</th>
      <th lay-data="{field:'paydate'}">支付时间</th>
      <!-- <th lay-data="{field:'dateline'}">添加时间</th> -->
      <!-- <th lay-data="{fixed: 'right', width:80, align:'center', toolbar: '#barDemo'}">操作</th> -->
  </thead>
</table>
<script type="text/html" id="barDemo">
  {{# if(d.status == 0){ }}
  <a class="layui-btn layui-btn-xs" lay-event="paysuccess">通过</a>
  <a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="payfail">拒绝</a>
  {{# } }}
</script>
{/block}
{block name="script"}
<script type="text/javascript">
  layui.use('table', function () {
    var table = layui.table;
    var $ = layui.$, active = {
      reload: function () {
        var demoReload = $('#demoReload');
        //执行重载
        table.reload('lists', {
          page: {
            curr: 1 //重新从第 1 页开始
          }
          , where: $('#searchForm').serializeObject()
        });
      }
    };
    $('.demoTable .layui-btn').on('click', function () {
      var type = $(this).data('type');
      active[type] ? active[type].call(this) : '';
    });
  });
  layui.use('laydate', function () {
    var laydate = layui.laydate;
    laydate.render({
      elem: '#startdate'
      , type: 'datetime'
      // ,value: "{:date('Y-m-d')}" + " 00:00:00"
    });
    laydate.render({
      elem: '#enddate'
      , type: 'datetime'
      // ,value: "{:date('Y-m-d H:i:s')}"
    });
  });
  function paysuccess(data) {
    layer.confirm('确定该订单支付已成功吗？', function () {
      $.post('/admin/ordervip/audit', { orderid: data.id, status: 1 }, function (datajson) {
        layer.msg(datajson.msg);
      });
    })
  }
  function payfail(data) {
    layer.confirm('确定该订单支付失败吗？', function () {
      $.post('/admin/ordervip/audit', { orderid: data.id, status: 0 }, function (datajson) {
        layer.msg(datajson.msg);
      });
    })
  }
</script>
{/block}